package com.sfh.cp.home.child;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sfh.cp.home.child.adapter.ContentAdapter;
import com.sfh.cp.home.pst.IPstCity;
import com.sfh.lib.mvp.IPresenter;
import com.sfh.lib.mvp.service.LoaderService;

import crm.sfh.server.entity.EContent;
import crm.sfh.server.entity.ENote;
import crm.sfh.server.entity.req.ReqPage;
import crm.sfh.server.entity.rsp.TPage;

/**
 * 首页-同城
 */

public class CityWideFragment extends BaseChildNoteFragment implements IPstCity.IVCity {


    public static CityWideFragment newFragment() {
        return new CityWideFragment();
    }

    IPstCity pstCity;

    @Nullable
    @Override
    public IPresenter getPresenter() {
        if (pstCity == null){
            pstCity = LoaderService.getService(IPstCity.class);
        }
        return pstCity;
    }

    @Override
    public void onRefreshUI() {

        nowPage = 1;
        ReqPage reqPage = new ReqPage(nowPage);
        pstCity.listPage(reqPage);
    }

    @Override
    public void onLoadMoreUI() {
        nowPage = +1;
        ReqPage reqPage = new ReqPage(nowPage);
        pstCity.listPage(reqPage);
    }

    @Override
    public void onClickFabulous(View v, ENote contentType) {
        pstCity.updateFabulous(contentType);
    }


    @Override
    public void onSuccess(TPage<EContent> page) {
        success(page);
    }

    @Override
    public void onError(String error) {
        error("", error);
    }
}
